/**
 * @Author 李彬
 * @Date: 2019年08月29日
 */
(function(win, doc) {
	// 1.获取 client 屏幕宽度
	const clien_width = doc.documentElement.clientWidth || doc.body.clientWidth;
	const new_height = doc.documentElement.clientHeight || doc.body.clientWidth;

	// console.log(clien_width/new_height);
	// console.log(new_height);
	// console.log(window.screen.height);
	// console.log((window.screen.height-new_height)/2);
	// 2.如果屏幕的宽度发生改变 触发 onresize 方法
	window.onresize = function() {
		const new_width = doc.documentElement.clientWidth || doc.body.clientWidth;
		// console.log("尺寸：" + new_width);
		fn(new_width);

		const new_height = doc.documentElement.clientHeight || doc.body.clientWidth;
		// console.log("高度：" + new_height);

//		fn(new_height);
	};

	//3. 【原始宽度】  或者  【改变后的宽度】 经过换算，赋值到 html=>style=>font-size    640px 是设计稿的原始尺寸
	var fn = function(width) {
		//console.log(width);
		//console.log(new_height);
		// 1920情况下
		if(970>new_height && new_height>935){
			const newWidth = doc.documentElement.style.fontSize = 6.8 * (width / 636) + "px";
		}else if(1080>=new_height && new_height>970){
			const newWidth = doc.documentElement.style.fontSize = 6.8 * (width / 590) + "px";
		}// 1440情况下
		else if(900>=new_height && new_height>790){
			// console.log(900);
			const newWidth = doc.documentElement.style.fontSize = 6.8 * (width / 530) + "px";
		}
		// 1600情况
		else if(789>=new_height && new_height>757){
			// console.log(757);
			const newWidth = doc.documentElement.style.fontSize = 6.8 * (width / 610) + "px";
		}
		// 1366情况下
		else if(756>=new_height && new_height>630){
			const newWidth = doc.documentElement.style.fontSize = 6.8 * (width / 600) + "px";
		}
		else {
			const newWidth = doc.documentElement.style.fontSize = 6.8 * (width / 640) + "px";
		}

		//console.log("屏幕尺寸：" + clien_width);
	};
	fn(clien_width);
})(window, document);

